services:
  web:
    build:
      context: ./docker/dev/runtimes/8.3
      dockerfile: Dockerfile
    ports:
      - 80:80
      - 5173:5173
    environment:
      XDG_CONFIG_HOME: /app/config
      XDG_DATA_HOME: /app/data
      XDG_CACHE_HOME: /app/cache
    extra_hosts:
      - host.docker.internal:host-gateway
    tty: true
    volumes:
      - ./www:/var/www/html
      - .env.example:/app/.env.example
      - app_config:/app/config
      - app_data:/app/data
    restart: unless-stopped
    depends_on:
      - mysql
      - redis
    networks:
      - app
    healthcheck:
      test:
        - CMD
        - php
        - artisan
        - octane:status
      interval: 2s
      timeout: 5s
      retries: 5
      start_period: 2s

  mysql:
    image: mysql:8
    ports:
      - 3306:3306
    environment:
      MYSQL_ALLOW_EMPTY_PASSWORD: 'yes'
      MYSQL_DATABASE: ${DB_DATABASE:-frankenstein}
      MYSQL_USER: ${DB_USERNAME:-frankenstein}
      MYSQL_PASSWORD: ${DB_PASSWORD:-password}
    volumes:
      - db:/var/lib/mysql
    restart: unless-stopped
    networks:
      - app
    healthcheck:
      test:
        - CMD
        - mysqladmin
        - ping
      interval: 2s
      timeout: 20s
      retries: 5
      start_period: 5s

  mailpit:
    image: axllent/mailpit
    restart: unless-stopped
    ports:
      - 1025:1025
      - 8025:8025
    networks:
      - app

  redis:
    build:
      context: ./docker/dev/redis
      dockerfile: Dockerfile
    ports:
      - 6379:6379
    environment:
      REDIS_PASSWORD: ${REDIS_PASSWORD:-password}
    volumes:
      - redis:/data
    networks:
      - app
    healthcheck:
      test:
        - CMD
        - redis-cli
        - ping
      timeout: 5s
      retries: 3

  queue:
    build:
      context: ./docker/dev/queue
      dockerfile: Dockerfile
    volumes:
      - ./www:/var/www/html
    restart: unless-stopped
    depends_on:
      - web
    networks:
      - app

  schedule:
    build:
      context: ./docker/dev/schedule
      dockerfile: Dockerfile
    restart: unless-stopped
    depends_on:
      - web
    networks:
      - app

volumes:
  app_data:
  app_config:
  redis:
  db:

networks:
  app:
